#测试我的题库页面
from time import sleep
from common.Untils import WJDriver
from selenium.webdriver.common.by import By
class WJIndex:
    url = ""
    driver = ""

    def __init__(self):
        #WJLogin.WJLogin().LoginSuccess()
        self.url = "http://8.155.1.153:8081/exercise"
        self.driver = WJDriver.driver
        self.driver.get(self.url)
        WJDriver.Login()
        #点击我的题库
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/aside/div/div[1]/ul/li[4]/div/span/div/span[2]").click()
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/aside/div/div[1]/ul/li[4]/ul/li[1]").click()

        # 进行页面元素的查找检查
    def TestByIndex(self):
        sleep(1)
        # 检查类型
        text = self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div/div/div/div/table/thead/tr/th[4]").text
        assert text == "类型"
        print("我的题库管理页面：类型")
        sleep(1)
        # 检查共享题库
        text = self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div/div/div/div/table/thead/tr/th[5]").text
        assert text == "共享题库"
        print("我的题库管理页面：共享题库")
        # 检查练习题库
        text = self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div/div/div/div/table/thead/tr/th[6]").text
        assert text == "练习题库"
        print("我的题库管理页面：练习题库")
        # 检查标签
        text = self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div/div/div/div/table/thead/tr/th[7]").text
        assert text == "标签"
        print("我的题库管理页面：标签")
        # 检查题目数量
        text = self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div/div/div/div/table/thead/tr/th[8]").text
        assert text == "题目数量"
        print("我的题库管理页面：题目数量")
        # 检查操作
        text = self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div/div/div/div/table/thead/tr/th[9]").text
        assert text == "操作"
        print("我的题库管理页面：操作")
        print("我的题库管理页面元素正常........")

        # 功能测试
    def TestByIndexFunction(self):
        # self.driver.find_element(By.CSS_SELECTOR,"").send_keys()
        # self.driver.find_element(By.CSS_SELECTOR,"").click()
        # 在名称输入框输入要查询的题目名字，选择类型“问卷”或“考试”，点击查询
        #输入名称
        self.driver.find_element(By.CSS_SELECTOR,"#name").send_keys("高数")
        #sleep(1)
        # 选择类型考试
        self.driver.find_element(By.CSS_SELECTOR, "#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div.ant-pro-card.ant-pro-table-search.ant-pro-table-search-query-filter > form > div > div:nth-child(2) > div > div > div.ant-col.ant-form-item-control > div > div > div > div").click()
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div/div/div[2]/div/div/div/div[2]/div").click()
        # 点击查询
        #sleep(1)
        self.driver.find_element(By.CSS_SELECTOR,"#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div.ant-pro-card.ant-pro-table-search.ant-pro-table-search-query-filter > form > div > div:nth-child(3) > div > div > div.ant-col.ant-form-item-control > div > div > div > div > div > div:nth-child(2) > button").click()
        #11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
        #点击重置
        self.driver.find_element(By.CSS_SELECTOR, "#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div.ant-pro-card.ant-pro-table-search.ant-pro-table-search-query-filter > form > div > div:nth-child(3) > div > div > div.ant-col.ant-form-item-control > div > div > div > div > div > div:nth-child(1) > button").click()
        #2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
        #点击新建，填写题库名称，标签，题库分类，题库类型，点击确定
            #点击新建
        #sleep(1)
        self.driver.find_element(By.CSS_SELECTOR, "#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div:nth-child(2) > div > div.ant-pro-table-list-toolbar > div > div.ant-space.ant-space-horizontal.ant-space-align-center.ant-pro-table-list-toolbar-right > div:nth-child(1) > div > div:nth-child(1) > button").click()
            #填写题库名称
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("高数"+WJDriver.name)
            #填写标签
        #self.driver.find_element(By.CSS_SELECTOR, "body > div:nth-child(9) > div > div.ant-drawer-content-wrapper > div > div > div.ant-drawer-body > form > div:nth-child(2) > div > div:nth-child(2) > div > div > div.ant-col.ant-form-item-control > div > div > div > div > div").send_keys("自动化测试")
            #填写题库分类
        self.driver.find_element(By.CSS_SELECTOR, "#category").send_keys("自动化测试")
            #填写题库类型
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[4]/div/div/div[2]/div/div/div/div[1]/span[1]/input").click()
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[4]/div/div/div[2]/div/div/div/div[2]/div/div/div/div[2]/div/div/div/div[2]/div").click()
            #点击添加到练习题库
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[6]/div/div/div[2]/div/div/button").click()
            #点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
        print("2正常")
        #33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
        #点击新建，填写题库名称，不填写标签，不填写题库分类，不填写题库类型，点击确定
            # 点击新建
        sleep(1)
        self.driver.find_element(By.CSS_SELECTOR,"#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div:nth-child(2) > div > div.ant-pro-table-list-toolbar > div > div.ant-space.ant-space-horizontal.ant-space-align-center.ant-pro-table-list-toolbar-right > div:nth-child(1) > div > div:nth-child(1) > button").click()
            # 填写题库名称
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("高数" + WJDriver.name)
            # 点击添加到练习题库
        #self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[6]/div/div/div[2]/div/div/button").click()
            # 点击确定
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
            #点击取消
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[1]/button").click()
        print("3正常")
        #44444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444
        #不填写题库名称，填写标签，不填写题库分类，填写题库类型，点击确定
            # 点击新建
        self.driver.find_element(By.CSS_SELECTOR,"#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div:nth-child(2) > div > div.ant-pro-table-list-toolbar > div > div.ant-space.ant-space-horizontal.ant-space-align-center.ant-pro-table-list-toolbar-right > div:nth-child(1) > div > div:nth-child(1) > button").click()
            # 填写标签
        # self.driver.find_element(By.CSS_SELECTOR, "body > div:nth-child(9) > div > div.ant-drawer-content-wrapper > div > div > div.ant-drawer-body > form > div:nth-child(2) > div > div:nth-child(2) > div > div > div.ant-col.ant-form-item-control > div > div > div > div > div").send_keys("自动化测试")
            # 填写题库类型
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[4]/div/div/div[2]/div/div/div/div[1]/span[1]/input").click()
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[4]/div/div/div[2]/div/div/div/div[2]/div/div/div/div[2]/div/div/div/div[2]/div").click()
            # 点击添加到练习题库
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[6]/div/div/div[2]/div/div/button").click()
            # 点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
            # 点击取消
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[1]/button").click()
        print("4正常")
        #55555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555
        sleep(1)
        #不填写题库名称，不填写标签，填写题库分类，不填写题库类型，点击确定
            # 点击新建
        self.driver.find_element(By.CSS_SELECTOR,"#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div:nth-child(2) > div > div.ant-pro-table-list-toolbar > div > div.ant-space.ant-space-horizontal.ant-space-align-center.ant-pro-table-list-toolbar-right > div:nth-child(1) > div > div:nth-child(1) > button").click()
            # 填写题库分类
        self.driver.find_element(By.CSS_SELECTOR, "#category").send_keys("自动化测试")
            # 点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
            # 点击取消
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[1]/button").click()
        print("5正常")
        #66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
        #填写题库名称，填写标签，填写题库分类，不填写题库类型，点击确定
            # 点击新建
        self.driver.find_element(By.CSS_SELECTOR,"#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div:nth-child(2) > div > div.ant-pro-table-list-toolbar > div > div.ant-space.ant-space-horizontal.ant-space-align-center.ant-pro-table-list-toolbar-right > div:nth-child(1) > div > div:nth-child(1) > button").click()
            # 填写标签
        # self.driver.find_element(By.CSS_SELECTOR, "body > div:nth-child(9) > div > div.ant-drawer-content-wrapper > div > div > div.ant-drawer-body > form > div:nth-child(2) > div > div:nth-child(2) > div > div > div.ant-col.ant-form-item-control > div > div > div > div > div").send_keys("自动化测试")
            # 填写题库分类
        self.driver.find_element(By.CSS_SELECTOR, "#category").send_keys("自动化测试")
            # 点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
            # 点击取消
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[1]/button").click()
        print("6正常")
        #777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
        #填写题库名称，不填写标签，不填写题库分类，填写题库类型，点击确定
            # 点击新建
        self.driver.find_element(By.CSS_SELECTOR,"#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div:nth-child(2) > div > div.ant-pro-table-list-toolbar > div > div.ant-space.ant-space-horizontal.ant-space-align-center.ant-pro-table-list-toolbar-right > div:nth-child(1) > div > div:nth-child(1) > button").click()
            # 填写题库类型
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[4]/div/div/div[2]/div/div/div/div[1]/span[1]/input").click()
        self.driver.find_element(By.XPATH,"/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[4]/div/div/div[2]/div/div/div/div[2]/div/div/div/div[2]/div/div/div/div[2]/div").click()
            # 点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
            # 点击取消
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[1]/button").click()
        print("7正常")
        #88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
        #点击文本导入,点击添加
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div/div/div/div/table/tbody/tr[2]/td[9]/div/div[1]/a").click()
        #self.driver.find_element(By.CLASS_NAME, "ant-btn ant-btn-primary").click()
        self.driver.refresh()
        #999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
        sleep(1)
        #点击模板导入,点击取消
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div/div/div/div/table/tbody/tr[2]/td[9]/div/div[2]/a").click()
        sleep(1)
        self.driver.find_element(By.XPATH, "/html/body/div[4]/div/div[2]/div/div[2]/div[3]/button[1]").click()
        #10#######################################################################################################################################################
        #点击试题管理,点击关闭
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div/div/div/div/table/tbody/tr[2]/td[9]/div/div[3]/a").click()
        self.driver.refresh()
        #sleep(1)
        print("我的题库页面全部正常...........")
        #self.driver.quit()
# index=WJIndex()
# index.TestByIndex()
# index.TestByIndexFunction()